package com.speljohan.rsbot.script.wrappers;

import com.speljohan.rsbot.accessors.NPC;
import com.speljohan.rsbot.accessors.NPCDef;

public class RSNPC extends RSCharacter {
	private final NPC npc;

	public RSNPC(final NPC npc) {
		super(npc);
		c = npc;
		this.npc = npc;
	}

	public String[] getActions() {
		final NPCDef def = getDefInternal();
		if (def != null) {
			return def.getActions();
		}
		return new String[0];
	}

	NPCDef getDefInternal() {
		if (npc == null) {
			return null;
		} else {
			return npc.getNPCDef();
		}
	}

	public int getID() {
		final NPCDef def = getDefInternal();
		if (def != null) {
			return def.getType();
		}
		return -1;
	}

	public String getName() {
		final NPCDef def = getDefInternal();
		if (def != null) {
			return def.getName();
		}
		return "";
	}

	@Override
	public String toString() {
		final StringBuilder sb = new StringBuilder();
		for (final String act : getActions()) {
			sb.append(act);
			sb.append(",");
		}
		if (sb.length() > 0) {
			sb.setLength(sb.length() - 1);
		}
		return "NPC[" + getName() + "],actions=[" + sb.toString() + "]"
		+ super.toString();
	}
}
